var setting ={
    showList: true,
    page: {
        pageNo: 10,
        total: 20,
        pageSize: 10,
        dataList: []
    },
    queryParam: {
        memo: '',
    },
    text: {
        submitButtonText:'添加',
    },
    options: [],
    selectedData: [],
    form: {
        memo: '',
    },
    loading: false,
    isAdd: true,
    imageUrl: ''
}
var vue = new Vue({
    el: '.main',
    data: setting,
    methods: {
        handleCurrentChange: function (pageNo) {//分页查询
            page(pageNo)
        },
        handleSizeChange: function (pageSize) {//修改pageSize查询
            vue.page.pageSize=pageSize
            page(1)
        },
        query: function () {//条件查询
            page(1)
        },
        getSelected: function (rows) {//获取选中内容
            vue.selectedData = rows;
        },
        changeAddOrEdit: function (type) {//切换添加
            if(type == 'add'){
                vue.text.submitButtonText = '添加';
                vue.isAdd = true;
            }else {
                vue.text.submitButtonText = '修改';
                var selectedData = vue.selectedData;
                if(selectedData.length == 0){
                    vue.$message.warning( '请选择要修改的数据');
                    return ;
                }else if(selectedData.length > 1){
                    vue.$message.warning( '请选择一条要修改的数据');
                    return ;
                }else {
                    vue.isAdd = false;
                }
            }
            vue.showList = false;
        },
        goBack: function () {
            vue.showList = true;
            vue.resetForm();
        },
        addOrEdit: function () {
            vue.loading = true;
            this.$refs.upload.submit();
        },
        success: function () {
            vue.loading = false;
            page(page.pageNo)
        }
    }
})
page(1)
function page(page) {
    var data = {
        page: page,
        pageSize: vue.page.pageSize,
        title: vue.queryParam.title,
    }
    $.post('/file/queryByPage', data, function (page) {
        vue.page.dataList = page.rows;
        vue.page.pageNo = page.page;
        vue.page.total = page.total;
    })
}